package androidx.transition;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.transition.Transition.b;
import o.fx;
import o.mw;
import o.ns;
import o.nu;
import o.nx;
import o.od;
import o.oe;
import o.oi;

public abstract class Visibility extends Transition {
    private static final String[] ˋ = new String[]{"android:visibility:visibility", "android:visibility:parent"};
    private int ʻ = 3;

    static class c {
        ViewGroup ʻ;
        int ˊ;
        ViewGroup ˋ;
        int ˎ;
        boolean ˏ;
        boolean ॱ;

        c() {
        }
    }

    static class e extends AnimatorListenerAdapter implements b, o.mw.e {
        private boolean ʻ;
        private final ViewGroup ˊ;
        private final boolean ˋ;
        private final int ˎ;
        boolean ˏ = false;
        private final View ॱ;

        e(View view, int i, boolean z) {
            this.ॱ = view;
            this.ˎ = i;
            this.ˊ = (ViewGroup) view.getParent();
            this.ˋ = z;
            ˎ(true);
        }

        public void onAnimationPause(Animator animator) {
            if (!this.ˏ) {
                oi.ˏ(this.ॱ, this.ˎ);
            }
        }

        public void onAnimationResume(Animator animator) {
            if (!this.ˏ) {
                oi.ˏ(this.ॱ, 0);
            }
        }

        public void onAnimationCancel(Animator animator) {
            this.ˏ = true;
        }

        public void onAnimationRepeat(Animator animator) {
        }

        public void onAnimationStart(Animator animator) {
        }

        public void onAnimationEnd(Animator animator) {
            ॱ();
        }

        public void ॱ(@NonNull Transition transition) {
        }

        public void ˋ(@NonNull Transition transition) {
            ॱ();
            transition.ॱ((b) this);
        }

        public void ˊ(@NonNull Transition transition) {
            ˎ(false);
        }

        public void ˏ(@NonNull Transition transition) {
            ˎ(true);
        }

        private void ॱ() {
            if (!this.ˏ) {
                oi.ˏ(this.ॱ, this.ˎ);
                if (this.ˊ != null) {
                    this.ˊ.invalidate();
                }
            }
            ˎ(false);
        }

        private void ˎ(boolean z) {
            if (this.ˋ && this.ʻ != z && this.ˊ != null) {
                this.ʻ = z;
                od.ˋ(this.ˊ, z);
            }
        }
    }

    public Visibility(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, ns.ˎ);
        int ˊ = fx.ˊ(obtainStyledAttributes, (XmlResourceParser) attributeSet, "transitionVisibilityMode", 0, 0);
        obtainStyledAttributes.recycle();
        if (ˊ != 0) {
            ˋ(ˊ);
        }
    }

    public void ˋ(int i) {
        if ((i & -4) != 0) {
            throw new IllegalArgumentException("Only MODE_IN and MODE_OUT flags are allowed");
        }
        this.ʻ = i;
    }

    public int ʻॱ() {
        return this.ʻ;
    }

    @Nullable
    public String[] ˋ() {
        return ˋ;
    }

    private void ˎ(nx nxVar) {
        nxVar.ˊ.put("android:visibility:visibility", Integer.valueOf(nxVar.ॱ.getVisibility()));
        nxVar.ˊ.put("android:visibility:parent", nxVar.ॱ.getParent());
        Object obj = new int[2];
        nxVar.ॱ.getLocationOnScreen(obj);
        nxVar.ˊ.put("android:visibility:screenLocation", obj);
    }

    public void ˋ(@NonNull nx nxVar) {
        ˎ(nxVar);
    }

    public void ॱ(@NonNull nx nxVar) {
        ˎ(nxVar);
    }

    private c ˊ(nx nxVar, nx nxVar2) {
        c cVar = new c();
        cVar.ॱ = false;
        cVar.ˏ = false;
        if (nxVar == null || !nxVar.ˊ.containsKey("android:visibility:visibility")) {
            cVar.ˊ = -1;
            cVar.ˋ = null;
        } else {
            cVar.ˊ = ((Integer) nxVar.ˊ.get("android:visibility:visibility")).intValue();
            cVar.ˋ = (ViewGroup) nxVar.ˊ.get("android:visibility:parent");
        }
        if (nxVar2 == null || !nxVar2.ˊ.containsKey("android:visibility:visibility")) {
            cVar.ˎ = -1;
            cVar.ʻ = null;
        } else {
            cVar.ˎ = ((Integer) nxVar2.ˊ.get("android:visibility:visibility")).intValue();
            cVar.ʻ = (ViewGroup) nxVar2.ˊ.get("android:visibility:parent");
        }
        if (nxVar == null || nxVar2 == null) {
            if (nxVar == null && cVar.ˎ == 0) {
                cVar.ˏ = true;
                cVar.ॱ = true;
            } else if (nxVar2 == null && cVar.ˊ == 0) {
                cVar.ˏ = false;
                cVar.ॱ = true;
            }
        } else if (cVar.ˊ == cVar.ˎ && cVar.ˋ == cVar.ʻ) {
            return cVar;
        } else {
            if (cVar.ˊ != cVar.ˎ) {
                if (cVar.ˊ == 0) {
                    cVar.ˏ = false;
                    cVar.ॱ = true;
                } else if (cVar.ˎ == 0) {
                    cVar.ˏ = true;
                    cVar.ॱ = true;
                }
            } else if (cVar.ʻ == null) {
                cVar.ˏ = false;
                cVar.ॱ = true;
            } else if (cVar.ˋ == null) {
                cVar.ˏ = true;
                cVar.ॱ = true;
            }
        }
        return cVar;
    }

    @Nullable
    public Animator ˋ(@NonNull ViewGroup viewGroup, @Nullable nx nxVar, @Nullable nx nxVar2) {
        c ˊ = ˊ(nxVar, nxVar2);
        if (!ˊ.ॱ || (ˊ.ˋ == null && ˊ.ʻ == null)) {
            return null;
        }
        if (ˊ.ˏ) {
            return ˎ(viewGroup, nxVar, ˊ.ˊ, nxVar2, ˊ.ˎ);
        }
        return ॱ(viewGroup, nxVar, ˊ.ˊ, nxVar2, ˊ.ˎ);
    }

    public Animator ˎ(ViewGroup viewGroup, nx nxVar, int i, nx nxVar2, int i2) {
        if ((this.ʻ & 1) != 1 || nxVar2 == null) {
            return null;
        }
        if (nxVar == null) {
            View view = (View) nxVar2.ॱ.getParent();
            if (ˊ(ˎ(view, false), ˊ(view, false)).ॱ) {
                return null;
            }
        }
        return ˏ(viewGroup, nxVar2.ॱ, nxVar, nxVar2);
    }

    public Animator ˏ(ViewGroup viewGroup, View view, nx nxVar, nx nxVar2) {
        return null;
    }

    public Animator ॱ(ViewGroup viewGroup, nx nxVar, int i, nx nxVar2, int i2) {
        Animator animator = null;
        if ((this.ʻ & 2) == 2) {
            View view;
            int id;
            View view2 = nxVar != null ? nxVar.ॱ : null;
            if (nxVar2 != null) {
                view = nxVar2.ॱ;
            } else {
                view = null;
            }
            if (view == null || view.getParent() == null) {
                if (view != null) {
                    view2 = view;
                    view = null;
                } else {
                    if (view2 != null) {
                        if (view2.getParent() == null) {
                            view = null;
                        } else if (view2.getParent() instanceof View) {
                            view = (View) view2.getParent();
                            if (ˊ(ˊ(view, true), ˎ(view, true)).ॱ) {
                                if (view.getParent() == null) {
                                    id = view.getId();
                                    if (!(id == -1 || viewGroup.findViewById(id) == null || !this.ʼ)) {
                                        view = view2;
                                    }
                                }
                                view = null;
                            } else {
                                view = nu.ˏ(viewGroup, view2, view);
                            }
                            view2 = view;
                            view = null;
                        }
                    }
                    view = null;
                    view2 = null;
                }
            } else if (i2 == 4) {
                view2 = null;
            } else if (view2 == view) {
                view2 = null;
            } else if (this.ʼ) {
                view = null;
            } else {
                view2 = nu.ˏ(viewGroup, view2, (View) view2.getParent());
                view = null;
            }
            if (view2 != null && nxVar != null) {
                int[] iArr = (int[]) nxVar.ˊ.get("android:visibility:screenLocation");
                int i3 = iArr[0];
                id = iArr[1];
                int[] iArr2 = new int[2];
                viewGroup.getLocationOnScreen(iArr2);
                view2.offsetLeftAndRight((i3 - iArr2[0]) - view2.getLeft());
                view2.offsetTopAndBottom((id - iArr2[1]) - view2.getTop());
                final oe ˊ = od.ˊ(viewGroup);
                ˊ.ˎ(view2);
                animator = ˊ(viewGroup, view2, nxVar, nxVar2);
                if (animator == null) {
                    ˊ.ॱ(view2);
                } else {
                    animator.addListener(new AnimatorListenerAdapter(this) {
                        final /* synthetic */ Visibility ˋ;

                        public void onAnimationEnd(Animator animator) {
                            ˊ.ॱ(view2);
                        }
                    });
                }
            } else if (view != null) {
                int visibility = view.getVisibility();
                oi.ˏ(view, 0);
                animator = ˊ(viewGroup, view, nxVar, nxVar2);
                if (animator != null) {
                    b eVar = new e(view, i2, true);
                    animator.addListener(eVar);
                    mw.ˊ(animator, eVar);
                    ˊ(eVar);
                } else {
                    oi.ˏ(view, visibility);
                }
            }
        }
        return animator;
    }

    public Animator ˊ(ViewGroup viewGroup, View view, nx nxVar, nx nxVar2) {
        return null;
    }

    public boolean ˎ(nx nxVar, nx nxVar2) {
        if (nxVar == null && nxVar2 == null) {
            return false;
        }
        if (nxVar != null && nxVar2 != null && nxVar2.ˊ.containsKey("android:visibility:visibility") != nxVar.ˊ.containsKey("android:visibility:visibility")) {
            return false;
        }
        c ˊ = ˊ(nxVar, nxVar2);
        if (!ˊ.ॱ) {
            return false;
        }
        if (ˊ.ˊ == 0 || ˊ.ˎ == 0) {
            return true;
        }
        return false;
    }
}
